<template>
???
  <section>
    ?????
    <!-- 添加 webkitdirectory 属性，上传文件夹 -->
    <a-input type="file" webkitdirectory id="uploadFile"  @change="handleChange"/>
    <!-- <input type="file" webkitdirectory id="uploadFile" @change="handleChange" /> -->
    <!-- <div v-for="item in submit.listt">{{item.webkitRelativePath}}</div> -->
   <a-button type="primary" @click="uploadPic">
      提交
    </a-button>
    
  </section>


</template>
<script setup>
////////////////////////////////////////////
import { reactive, ref } from "vue";
import { post, setLocalToken,tip } from "@/common";
import { useRouter } from "vue-router";
import { get } from "@/common";
import { message } from "ant-design-vue";
////////////////////////////////////////////
const submit = reactive({
  listt:[],
  currentQuestion:{},   //当前需求信息
  currentFile:null,   //当前图片文件
  currentImgUrl:null,    //当前图片路径
  

});
const handleChange = () => {
  let files = document.getElementById("uploadFile").files; // FileList 伪数组对象
      submit.listt = files;
      for (let i = 0; i <= files.length - 1; i++) {
        let file = files[i]; // File 对象
        console.log(file);
        
}
};

const requestID=reactive(
   "wdnmd"
)


const uploadPic = () => {
  let files = document.getElementById("uploadFile").files; // FileList 伪数组对象   
  var  picData =[]
  const mydata = new FormData();
  
   for (let i = 0; i <= files.length-1 ; i++) {
  mydata.append("files",files[i]);
  console.log("添加一个文件")
   };
     console.log(mydata.getAll('files'))
     picData=mydata.getAll('files')
     console.log("picData:")
     console.log(picData)
  post("/demander/submit/pic?path="+requestID,mydata).then((res) => {
    
    console.log(res)
    tip.success(res.message)

  });
  
 
};


</script>
<style>

</style>